package game.block.sound;

import game.block.Constants;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.math.MathUtils;

public class ConsoleAudio implements IAudio, Constants {

    private ArrayList<Music> musicList;
    private Music music;
    private float soundFXVolume;
    public static float DEFAULT_VOLUME = 0.5f;

    public ConsoleAudio() {
        soundFXVolume = DEFAULT_VOLUME;
        Music m = Gdx.audio.newMusic(Gdx.files.internal("data/sound/puzzle_music1.mp3"));
        Music m1 = Gdx.audio.newMusic(Gdx.files.internal("data/sound/puzzle_music2.mp3"));
        Music m2 = Gdx.audio.newMusic(Gdx.files.internal("data/sound/puzzle_music3.mp3"));
        Music m3 = Gdx.audio.newMusic(Gdx.files.internal("data/sound/puzzle_music4.mp3"));
        
        
        musicList = new ArrayList<Music>();

        musicList.add(m);
        musicList.add(m1);
        musicList.add(m2);
        musicList.add(m3);
    }

    @Override
    public void pickMusic() {
        music = musicList.get(MathUtils.random(3));
        playMusic();
    }

    @Override
    public void playSound(int soundID) {
        Constants.soundList[soundID].play(soundFXVolume);
    }

    @Override
    public void stopSound(int soundID) {
        Constants.soundList[soundID].stop();
    }

    @Override
    public void stopAllSounds() {
    }

    @Override
    public void playMusic() {
        music.play();
        music.setVolume(DEFAULT_VOLUME);
        music.setLooping(false);
    }

    @Override
    public void stopMusic() {
        music.pause();
    }

    @Override
    public void setSoundFXVolume(float vol) {
        soundFXVolume = vol;
    }

    @Override
    public void setMusicVolume(float vol) {
        music.setVolume(vol);

    }

    @Override
    public Music getMusic() {
        return music;
    }

}
